/********************************************************************************
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 2 of the License, or (at your option) any later 	*
* version. This program is distributed in the hope that it will be useful, but 	*
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more *
* details. You should have received a copy of the GNU General Public License 	*
* along with this program; if not, write to the Free Software Foundation, Inc., *
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.						*
* (c) Copyright 2012 José Delgado Pérez, josedelgado@ula.ve josed43@gmail.com.	*				*
********************************************************************************/

/**
 @file servoMotor.cpp
 @brief Desarrollo e implementación de los métodos de la clase SERVOMOTOR_H para manejo del Servo Motor.
 @date Diciembre, 2012.
 @author José Delgado Pérez, josedelgado@ula.ve josed43@gmail.com.
 @version 0.9
*/

#include <Arduino.h>
#include "Servo/Servo.h"
#include "servoMotor.h"

/****** Métodos de manipulación del Servo Motor ******/

servoMotor::servoMotor(){
	_pin = NULL;

}

/**************************************************************************************************/

servoMotor::servoMotor(int pin){
	_pin = pin;
	servomotor.attach(_pin);
}

/**************************************************************************************************/

void servoMotor::inicializarServo(int pin) {
	int anguloInicial = 180;
	_pin = pin;
	servomotor.attach(_pin);
	servomotor.write(anguloInicial);
}

/**************************************************************************************************/

void servoMotor::escribirServomotor(int angulo){
	servomotor.write(angulo);
}

/**************************************************************************************************/

int servoMotor::getPin() const {
	return _pin;
}

/**************************************************************************************************/

void servoMotor::setPin(int pin) {
	_pin = pin;
}

/**************************************************************************************************/

const Servo& servoMotor::getServomotorUs() const {
	return servomotor;
}

/**************************************************************************************************/

void servoMotor::setServomotorUs(const Servo& servomotorUs) {
	servomotor = servomotorUs;
}

/**************************************************************************************************/

servoMotor::~servoMotor() {
	_pin = NULL;
	servomotor.detach();
}
